package com.im.app.service.impl;

import com.im.app.mapper.ConversationsMapper;
import com.im.app.model.Conversations;
import com.im.app.service.ConversationsService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;


@Service
@Transactional(rollbackFor = Exception.class)
@Slf4j
public class ConversationsServiceImpl implements ConversationsService {

    @Resource
    private ConversationsMapper conversationsMapper;


    @Override
    public int insert(Conversations conversations) {
        return conversationsMapper.insert(conversations);
    }

    @Override
    public Conversations selectByGroup(String ownerUserId, String groupId) {
        return conversationsMapper.selectByGroup(ownerUserId, groupId);
    }

    @Override
    public Conversations selectByUser(String ownerUserId, String userId) {
        return conversationsMapper.selectByUser(ownerUserId,userId);
    }

    @Override
    public int updateByGroup(Conversations conversations) {
        return conversationsMapper.updateById(conversations);
    }

    @Override
    public int updateByUser(Conversations conversations) {
        return conversationsMapper.updateById(conversations);
    }

    @Override
    public int updateIsPinned(Integer isPinned,String conversationId) {
        return conversationsMapper.updateIsPinned(isPinned,conversationId);
    }

    @Override
    public int clearUnreadCount(String conversationId) {
        return conversationsMapper.clearUnreadCount(conversationId);
    }



}

